
FUNCTION LCB_Norm_nToNorm_a :INT
TITLE = 'LCB_Norm_nToNorm_a'
//
// This function converts a scaled 32-bit signal into a scaled 16-bit signal.
//
// Versionshistory:
// 1.0 Ersterstellung R.Enders

VERSION : '1.0'
AUTHOR  : 'Lenze'
FAMILY  : 'LCB'
NAME : 'NnToNa' // ( 8 Zeichen max.)
KNOW_HOW_PROTECT


VAR_INPUT
    diIn_n : DINT;
END_VAR

VAR_IN_OUT
    
END_VAR

VAR_OUTPUT
    
END_VAR

// Temp
VAR
    tmp1:INT;
    tmp2:DWORD;
    
    
     END_VAR

BEGIN
  
   //  LCB_Norm_nToNorm_a :=LIMIT(MN:= -32767,
   //                             IN:=DWORD_TO_INT
    //                            (SHR( IN:= DINT_TO_DWORD (diIn_n), N:=16)),
     //                           MX:=32767);
     
     tmp2:= DINT_TO_DWORD (diIn_n);
     tmp2:= SHR ( IN:=tmp2,N:=16);
     tmp1:= DWORD_TO_INT (tmp2);
     LCB_Norm_nToNorm_a :=LIMIT(MN:= -32767,IN:=tmp1,MX:=32767);

     
     
END_FUNCTION